package com.yike.user.controller.feign;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yike.common.base.BaseController;
import com.yike.user.api.vo.ShopFeignVo;
import com.yike.user.mapper.ShopMapper;
import com.yike.user.service.PlatformShopService;
import com.yike.user.vo.PlatformShopVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * 权限表 控制器
 *
 * @author yike
 * @since 2023-08-24
 */
@Slf4j
@RestController
@RequestMapping("/feign/shop")
@ApiIgnore
public class ShopFeignController extends BaseController {

    @Autowired
    private ShopMapper shopMapper;

    @Autowired
    private PlatformShopService  platformShopService;
    /**
     * 获取当前url所需权限
     */
    @GetMapping("/getShop")
    public ShopFeignVo getShop(Long shopId) throws Exception {
        return shopMapper.getShopFeignVo(shopId);
    }

    @GetMapping("/getShopDetails")
    public Map getShopDetails(Long shopId) throws Exception {
        PlatformShopVo platformShopVo = platformShopService.getShop(shopId);
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.convertValue(platformShopVo, Map.class);
    }



}

